<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="but">弹出层</button>
    <div class="he" style="display: none;">
        <span class="gb">X</span>
    </div>
</body>
</html>
<style>
    .but{
        margin: 0 auto;
    }
    .he{
        width: 200px;
        height: 200px;
        background-color: skyblue;
    }
    .gb{
        display: inline-block;
        margin: 0 180px;
    }
</style>
<script>
    var but=document.querySelector(".but")
    var he=document.querySelector(".he")
    var gb=document.querySelector(".gb")
    but.onclick=function(){
        he.style.display="block"
    }
    gb.onclick=function(){
        he.style.display="none"
    }
</script>